package cn.xopencode.recordservice.manager.kvoperation;

import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.convert.kvoperation.KvOperationRecordConvert;
import cn.xopencode.recordservice.convert.robotroom.AdminRecordConvert;
import cn.xopencode.recordservice.rpc.kvoperation.dto.*;
import cn.xopencode.recordservice.rpc.kvoperation.vo.*;
import cn.xopencode.recordservice.rpc.robotroom.dto.AdminRecordPageDTO;
import cn.xopencode.recordservice.service.kvoperation.KvOperationRecordService;
import cn.xopencode.recordservice.service.kvoperation.bo.KvOperationRecordBO;
import cn.xopencode.recordservice.service.kvoperation.bo.KvOperationRecordNextCreateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class KvOperationRecordManager {

    @Autowired
    private KvOperationRecordService kvOperationRecordService;

    public PageResult<KvOperationRecordPageVO> pageKvOperationRecord(KvOperationRecordPageDTO pageDTO){
        return kvOperationRecordService.pageKvOperationRecord(KvOperationRecordConvert.INSTANCE.convert(pageDTO));
    }

    public KvOperationRecordCreateVO createKvOperationRecord(KvOperationRecordCreateDTO createDTO){
        KvOperationRecordBO createBo = KvOperationRecordConvert.INSTANCE.convert(createDTO);
        String recordCode = kvOperationRecordService.createKvOperationRecord(createBo);
        KvOperationRecordCreateVO kvOperationRecordCreateVO = new KvOperationRecordCreateVO();
        kvOperationRecordCreateVO.setRecordCode(recordCode);
        return kvOperationRecordCreateVO;
    }

    public Integer createKvOperationRecordNextLine(KvOperationRecordNextCreateDTO nextCreateDTO){
        return kvOperationRecordService.createKvOperationRecordNextLine(KvOperationRecordConvert.INSTANCE.convert(nextCreateDTO));
    }

    public KvOperationRecordVO getKvOperationRecordById(String recordId){
        return kvOperationRecordService.getKvOperationRecordById(recordId);
    }

    public KvOperationRecordNextVO getKvOperationRecordNextById(String recordCode,Integer recordSeq){
        return  kvOperationRecordService.getKvOperationRecordNextById(recordCode,recordSeq);
    }

    public Integer updateKvOperationRecord(KvOperationRecordUpdateDTO updateDTO){
        KvOperationRecordBO recordBo = KvOperationRecordConvert.INSTANCE.convert(updateDTO);
        return kvOperationRecordService.updateKvOperationRecord(recordBo);
    }

    public Integer updateKvOperationRecordNextLine(KvOperationRecordNextUpdateDTO nextUpdateDTO){
        KvOperationRecordNextCreateBO nextCreateBO = KvOperationRecordConvert.INSTANCE.convert(nextUpdateDTO);
        return kvOperationRecordService.updateKvOperationRecordNextLine(nextCreateBO);
    }

    public Integer dealKvOperationRecordLineException(String recordDetailId){
        return kvOperationRecordService.dealKvOperationRecordLineException(recordDetailId);
    }

    public PageResult<KvOperationRecordAdminPageVO> getAdminPage10KvOperationRecord(AdminRecordPageDTO pageDTO){
        return kvOperationRecordService.getAdminPage10KvOperationRecord(AdminRecordConvert.INSTANCE.convert(pageDTO));
    }
}
